#编写脚本测试192.168.4.0/24整个网段中哪些主机处于开机状态，哪些主机处于关机状态

#!/bin/bash
for  i  in   {1..254}
do
  ping -c2 -i0.3 -W1 192.168.4.$i  &>/dev/null
  if [ $? -eq 0 ];then
     echo "192.168.4.$i is up"
  else
     echo  "192.168.4.$i is down"
  fi
done